# Maintainer: Ben Fuhrmannek <ben+alpine@sektioneins.de>
pkgname=tcl.gd
pkgver=1.3.1
pkgrel=0
pkgdesc="Tcl interface to the GD drawing library"
url="https://flightaware.github.io/tcl.gd/"
arch="all"
license="BSD-3-Clause"
depends="tcl"
makedepends="gd-dev tcl-dev autoconf"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/flightaware/tcl.gd/archive/v$pkgver.tar.gz"

prepare() {
	default_prepare

	autoconf
}

build() {
	# shellcheck disable=SC1091
	. /usr/lib/tclConfig.sh

	local extra_configure_flags
	if echo "$TCL_DEFS" | grep -q "DTCL_CFG_DO64BIT=1"; then
		extra_configure_flags="--enable-64bit"
	fi

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-threads \
		$extra_configure_flags

	make
}

check() {
	make test
}

package() {
	make -j1 DESTDIR="$pkgdir" install
}

sha512sums="
09567b58c8a4f3709412878e4c39d78456f18875f64aaefb3d584093063ee626eed5a2d980f42711b48ec3596b3a342be692dba8bebdf30d83ba4f1961a1e7d3  tcl.gd-1.3.1.tar.gz
"
